package com.wen.common.exception;

import com.wen.common.enums.CodeEnum;

//如果不要求调用者一定要 处理抛出的异常，就继承RuntimeException
public class CustomException extends RuntimeException {

    private String errorCode;
    private String errorMsg;

    public CustomException(){
        super();
    }

    public CustomException(String message) {
        super(message);
    }

    public CustomException(String errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public CustomException(String errorCode, String errorMsg, String source) {
        this(errorCode, String.format("%s [%s]", errorMsg, source));
    }

    public CustomException(CodeEnum status, String source) {
        this(status.getResultCode(), status.getResultMsg(), source);
    }

    // getter & setter

    public String getErrorCode() {
        return errorCode;
    }

    public void setErrorCode(String errorCode) {
        this.errorCode = errorCode;
    }

    public String getErrorMsg() {
        return errorMsg;
    }

    public void setErrorMsg(String errorMsg) {
        this.errorMsg = errorMsg;
    }
}
